#define  _CRT_SECURE_NO_WARNINGS

#include "Heap.h"
#include "BT.h"

void test() {
	int arr[] = { 27,15,19,18,28,34,65,49,37 };
	HP hp;
	HeapInit(&hp);
	for (int i = 0; i < sizeof(arr) / sizeof(int); i++) {
		HeapPush(&hp, arr[i]);
	}
	HeapPrint(&hp);

	HeapPop(&hp);
	HeapPrint(&hp);

	//for (int i = 0; i < 8; i++) {
	//	printf("%d ", HeapTop(&hp));
	//	HeapPop(&hp);
	//}

	PrintTopK(hp.arr, hp.size, 8);

	HeapDestroy(&hp);
}

void test2() {
	int arr[] = { 27,15,19,18,28,34,65,49,37 };
	HP hp;
	HeapCreate(&hp, arr, sizeof(arr) / sizeof(int));
	HeapPrint(&hp);
}

void test3() {
	int arr[] = { 27,15,19,18,28,34,65,49,37 };
	HeapSort(arr, sizeof(arr)/sizeof(arr[0]));
	for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++) {
		printf("%d ", arr[i]);
	}
}

void test4() {
	BTNode* n1 = BuyBTNode(1);
	BTNode* n2 = BuyBTNode(2);
	BTNode* n3 = BuyBTNode(3);
	BTNode* n4 = BuyBTNode(4);
	BTNode* n5 = BuyBTNode(5);
	BTNode* n6 = BuyBTNode(6);
	BTNode* n7 = BuyBTNode(7);
	n1->left = n2;
	n1->right = n3;
	n2->left = n4;
	n2->right = n5;
	n3->right = n6;
	n3->left = n7;

	PrevOrder(n1);
	printf("\n");
	LevelOrder(n1);
	printf("\n");
	printf("%d\n", TreeLeafSize(n1));
	printf("%d\n", TreeHeight(n1));
	printf("%d\n", TreeKLevelSize(n1,3));
	
	printf("%p\n", TreeFind(n1, 8));

	printf("%d\n", TreeComplete(n1));

	TreeDestroy(&n1);
	PrevOrder(n1);
}


int main() {
	test4();
	return 0;
}